package main

import (
	"context"
	"net"

	"google.golang.org/grpc"

	"go-code/src/grpc_test/proto"
)
type Server struct{
	proto.UnimplementedGreeterServer
}

func (s *Server) SayHello(ctx context.Context,request *proto.HelloRequest) (*proto.HelloReply,
	error){
		return &proto.HelloReply{
			Message: "hello" + request.Name,
		},nil
}

// func (s *Server) mustEmbedUnimplementedGreeterServer() {
// 	// 嵌入 UnimplementedGreeterServer 类型，保证接口完整性
// }

func main(){
	g := grpc.NewServer()
	proto.RegisterGreeterServer(g, &Server{})
	lis, err := net.Listen("tcp","0.0.0.0:8088")
	if err != nil{
		panic("fail 通listen："+ err.Error())
		}	
		err = g.Serve(lis)
		if err != nil{
			panic("failed to start grpc:" + err.Error())
		}
}